package patterns.flyweight;

import java.util.HashMap;

/**
 * Created by lenovo on 2016/11/28 0028.
 * Shape的工厂类，在此提供对外的对象调用，根据条件生成不同的对象，并在hashmap中保存引用
 */
public class ShapeFactory {
    private static HashMap<String,IShape> circleMap = new HashMap<>();

    public static IShape getCircle(String color){
        Circle circle = (Circle) circleMap.get(color);
        if (circle ==null){
            circle = new Circle(color);
            circleMap.put(color,circle);
        }
        return circle;
    }
}
